//
// Created by 25313 on 2025/8/5.
//
class RecentCounter {
public:
    queue<int> q;
    RecentCounter() {

    }

    int ping(int t) {
        while(!q.empty())
        {
            int time = q.front();
            if(time < t - 3000)
            {
                q.pop();
            }else{
                break;
            }
        }
        q.push(t);
        return q.size();
    }
};